package com.share.design.status.demo01;

import java.util.Objects;

/**
 * 包裹
 * @author caifan
 * @since 2022/11/6
 */
public class PackageContext {
    private PackageState currentState;
    private String packageId;

    public PackageContext(PackageState currentState, String packageId) {
        this.currentState = currentState;
        this.packageId = packageId;
        if (Objects.isNull(currentState)) {
            this.currentState = Acknowledged.getInstance();
        }
    }

    public PackageState getCurrentState() {
        return currentState;
    }

    public void setCurrentState(PackageState currentState) {
        this.currentState = currentState;
    }

    public String getPackageId() {
        return packageId;
    }

    public void setPackageId(String packageId) {
        this.packageId = packageId;
    }

    public void update() {
        currentState.updateState(this);
    }
}
